package middleware

import (
	"editor/constant"
	"editor/utils"

	"github.com/gin-gonic/gin"
)

func Session() gin.HandlerFunc {
	return func(c *gin.Context) {
		if utils.GetSession(c, constant.UserName) == constant.Config.Login.User {
			c.Set(constant.UserName, constant.Config.Login.User)
		} else {
			c.Set(constant.UserName, "")
		}
		c.Next()
	}
}
